<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="提交时间" prop="submitTime">
        <el-date-picker clearable
                        v-model="queryParams.submitTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择提交时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="提交人" prop="submitBy">
        <el-input
          v-model="queryParams.submitBy"
          placeholder="请输入提交人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="检查情况" prop="feedback">
        <el-select v-model="queryParams.feedback" placeholder="请选择检查情况" clearable @change="handleQuery">
          <el-option
            v-for="dictItem in dict.type.ya_task_qualified"
            :key="dictItem.value"
            :label="dictItem.label"
            :value="dictItem.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="stage_tasks_submitList" @selection-change="handleSelectionChange">
      <el-table-column label="任务名称" align="center" prop="taskName" />
      <el-table-column label="学生名称" align="center" prop="name" />
      <el-table-column label="附件" align="center" prop="attachment">
        <template slot-scope="scope">
          <a v-if="scope.row.attachment" :href="scope.row.attachment" target="_blank">
            <image-preview :src="fileIcon" alt="File" :width="50" :height="50"/>
          </a>
          <span v-else>未上传</span>
        </template>
      </el-table-column>
      <el-table-column label="提交时间" align="center" prop="submitTime" width="180">
        <template slot-scope="scope">
          <!-- 修改时间格式为精确到时分秒 -->
          <span>{{ parseTime(scope.row.submitTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="提交人" align="center" prop="submitBy" />
      <el-table-column label="检查情况" align="center" prop="feedback">
        <template slot-scope="scope">
          <span v-if="scope.row.feedback!== null">
            <dict-tag :options="dict.type.ya_task_qualified" :value="scope.row.feedback"/>
          </span>
          <span v-else>未检查</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { listStage_tasks_submit } from "@/api/teaching/stage_tasks_submit";
import fileIcon from '@/assets/images/file.png';

export default {
  name: "Stage_tasks_submit",
  dicts: ['ya_task_qualified'],
  data() {
    return {
      // 文件图片
      fileIcon: fileIcon,
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 任务提交表格数据
      stage_tasks_submitList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        attachment: null,
        submitTime: null,
        submitStatus: null,
        createdBy: null,
        feedback: null
      },
      // 表单参数
      form: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询任务提交列表 */
    getList() {
      this.loading = true;
      listStage_tasks_submit(this.queryParams).then(response => {
        this.stage_tasks_submitList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>
